// pages/Tabbar/My/mineTeam/mineTeam.js
//获取应用实例
const app = getApp()
const assetsAddress = app.globalData.global.assetsIp + '/' + app.globalData.global.assetsName;
import { queryUserTeam } from '../../../../api/user';

Page({

  /**
   * 页面的初始数据
   */
  data: {
    windowH:wx.getWindowInfo().screenHeight-(wx.getWindowInfo().screenHeight-wx.getWindowInfo().safeArea.bottom)-wx.getWindowInfo().statusBarHeight-44-15,
    contentH:378,
    assetsAddress: assetsAddress,
    triggered: false,
    page: 1,
    direct_recommend_count:0,
    direct_recommend_client_count:0,
    team_fnfos:[],
    shareTitle: app.globalData.global.shareTitle,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getData();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
    let userId = wx.getStorageSync('userId')
    return {
      title: this.data.shareTitle,
      path: '/pages/Tabbar/Home/Home?scene='+userId,
    }
  },
  // 获取我的团队信息
  getData(){
    let _this = this;
    queryUserTeam()
    .then(res => {
      if(res.success){
        _this.setData({
          direct_recommend_count: res.data.oneLevelUserCount,
          direct_recommend_client_count: res.data.oneLevelCustomerCount,
          team_fnfos: res.data.users ?? [],
          triggered: false,
        })
      }else{
        wx.showToast({
          title: res.errMessage,
          icon: 'none',
        })
      }
    })
  },
  // 下拉刷新
  onRefresh(){
    this.getData();
  },
})